import math


def maxSubArray(nums: [int]):
    ans = nums[0]
    sum = 0
    for num in nums:
        if(sum > 0):
            sum += num
        else:
            sum = num

        ans = max(ans,sum)

    return ans


a = maxSubArray([1,2,3,4,-9,6])
print(a)